#include <iostream>
#include <vector>
#include <unistd.h>

using namespace std;

typedef void (*func_t)();    //函数指针

void PrintLOG()
{
    //打印日志信息
    cout << "pid: " << getpid() << " 输出日志信息……" << endl;
}

void InsertMySQL()
{
    //插入 SQL 信息
    cout << "pid: " << getpid() << " 插入SQL信息……" << endl;
}

void NetRequst()
{
    //执行网络请求
    cout << "pid: " << getpid() << " 进行网络请求……" << endl;
}

#define COMMAND_LOG 0
#define COMMAND_MYSQL 1
#define COMMAND_NET 2

class Task
{
public:
    Task()
    {
        funcs.push_back(PrintLOG);
        funcs.push_back(InsertMySQL);
        funcs.push_back(NetRequst);
    }

    void Execute(int command)
    {
        if(command >= 0 && command < funcs.size())
            funcs[command](); //执行对应任务
    }

private:
    vector<func_t> funcs;   //任务列表
};